/*
 * @lc app=leetcode.cn id=1441 lang=javascript
 *
 * [1441] 用栈操作构建数组
 */

// @lc code=start
/**
 * @param {number[]} target
 * @param {number} n
 * @return {string[]}
 */
var buildArray = function (target, n) {
  let k = 0;
  const res = [];
  for (let i = 1; i <= n; i++) {
    if (i === target[k]) {
      res.push('Push');
      if (++k >= target.length) {
        break;
      }
    } else {
      res.push('Push', 'Pop');
    }
  }
  return res;
};
// @lc code=end

